package cn.dt.ymcc.feignclient;

import cn.dt.ymcc.doc.CourseDoc;
import cn.dt.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class SearchsFeignClientFallbackFactory implements FallbackFactory<SearchsFeignClient> {
    @Override
    public SearchsFeignClient create(Throwable throwable) {
        return new SearchsFeignClient() {
            @Override
            public JSONResult saveCourse(CourseDoc doc) {
                throwable.printStackTrace();;
                return JSONResult.error("搜索服务不可达，请检查搜索服务的新增");
            }

            @Override
            public JSONResult deleteCourse(CourseDoc doc) {
                throwable.printStackTrace();;
                return JSONResult.error("搜索服务不可达，请检查搜索服务的删除功能");
            }
        };
    }
}
